import request from '@/router/axios';
import {baseUrl} from "../../config/env";

export const getList = (current, size, params) => {
  return request({
    url: baseUrl + '/api-user/topmenu/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: baseUrl + '/api-user/topmenu/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: baseUrl + '/api-user/topmenu/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: baseUrl + '/api-user/topmenu/save',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: baseUrl + '/api-user/topmenu/update',
    method: 'post',
    data: row
  })
}

export const getMenuTree = () => {
  return request({
    url: baseUrl + '/api-user/menus/topMenu',
    method: 'get',
    // data: row
  })
}

export const grant = (id, menuIds) => {
  return request({
    url: baseUrl + '/api-user/topmenu/granted',
    method: 'post',
    data: {
      id,
      menuIds
    }
  })
}
export const getMenuByTopId = (id) => {
  return request({
    url: baseUrl + '/api-user/topmenu/getMenuByTopId',
    method: 'get',
    params: {
      id
    }
  })
}

